﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace AllenalaMente.Games
{
    public partial class GameRecap : UserControl
    {
        private State.GameState gameState = State.GameStateManager.GetState();

        public GameRecap(GameEventArgs args)
        {
            InitializeComponent();

            textBlockScore.Text = args.score.ToString() + " " + Locale.Strings.Points.ToLower();

            // Giuste
            textBlockGiuste.Text = args.giuste.ToString();

            // Sbagliate
            textBlockSbagliate.Text = args.sbagliate.ToString();

            // Bonus Precisione
            textBlockBonus.Text = "";

            if (args.sbagliate == 0)
            {
                int bonus = args.giuste * 10;
                textBlockBonus.Text = "Bonus + " + bonus;
                args.score += bonus;
            }

            // Aggiorna punteggi in modalità practice
            if (gameState.gameMode == State.GameMode.Practice)
            {
                int score = args.score;
                int index = args.index;

                gameState.GamesList[index].score = score;

                if (score > gameState.GamesList[index].recordScore)
                {
                    gameState.GamesList[index].recordScore = score;
                }
            }
        }
    }
}
